// formats.cpp
// Customizer
// Protea Customizer / Business Logic for managing formats (buffers)
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// Please send correspondence to:
//
// theproteaproject@gmail.com
//

#include "customizer.h"

//////////////////////////////////////////////////////////
//
// Transaction code
//
//////////////////////////////////////////////////////////


//
//@ CHA AddFormat
//@ COD AddFormat
//@ NUM 190
//@ CRI FORMAT_NAME
//@ TAB FORMAT_DESCRIPTR Write 
//@ TAB FORMAT_NBR_POOL Write 
//
//@ GEN AddFormat will create a new format, writing a new FORMAT_DESCRIPTR record
//
TRANSACTION_CODE( AddFormat ) {
	//@ GRS Start the transaction
	START_TXN( AddFormat );
		//@ Start the database transaction
		START_DB_TXN();

			AddFormatInternal( &txnvars, false );

		END_DB_TXN();

		//@ Output a LOG transaction
		LOG_TRANSACTION();

		//@ Send back result buffer
		App->TransResponse( txnvars.result, txnvars.buffer, TRANS_HEADER_TYPE );

	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};



//
//@ CHA DelFormat
//@ COD DelFormat
//@ NUM 190
//@ CRI FORMAT_NAME
//@ TAB FORMAT_DESCRIPTR Write 
//@ TAB FORMAT_NBR_POOL Write 
//
//@ GEN DelFormat will delete a FORMAT_DESCRIPTR record
//
TRANSACTION_CODE( DeleteFormat ) {

	//@ GRS Start the transaction
	START_TXN( DeleteFormat );

		//@ Start database transaction
		START_DB_TXN();
			DelFormatInternal( &txnvars, false );
		END_DB_TXN();

		//@ End the transaction
		LOG_TRANSACTION();

	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};



//
//@ CHA ChgFormat
//@ COD ChgFormat
//@ NUM 190
//@ CRI FORMAT_NAME
//@ CRI APPL_NBR
//@ TAB FORMAT_DESCRIPTR Write
//
//@ GEN ChgFormat will change FORMAT_DESCRIPTR records
//
TRANSACTION_CODE( ChgFormat ) {

	//@ GRS Start the transaction
	START_TXN( ChgFormat );
		START_DB_TXN();
			ChgFormatInternal( &txnvars, false );
		END_DB_TXN();

		LOG_TRANSACTION();

		//@ Send back result buffer
		App->TransResponse( txnvars.result, txnvars.buffer, TRANS_HEADER_TYPE );

	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};





//
//@ CHA CopyFormat
//@ COD CopyFormat
//@ NUM 190
//@ CRI FORMAT_NAME
//@ TAB FORMAT_DESCRIPTR Write 
//@ TAB FORMAT_NBR_POOL Write 
//@ TAB APPL_DEFN Write
//
//@ GEN CopyFormat will create a new format, writing a new FORMAT_DESCRIPTR record
//
TRANSACTION_CODE( CopyFormat ) {
	//@ GRS Start the transaction
	START_TXN( CopyFormat );
		//@ Start the database transaction
		START_DB_TXN();
			CopyFormatInternal( &txnvars, false );
		END_DB_TXN();

		LOG_TRANSACTION();
	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};
